class Animal:
    def speak(self):
        print("我是动物，我会说话")
class People(Animal):
    def speak(self):
        print("say hello")

class Dog(Animal):
    def speak(self):
        print("汪汪汪")

class Pig(Animal):
    def speak(self):
        print("哼哼哼")

# 三个对象都是动物
obj1 = People()
obj2 = Dog()
obj3 = Pig()

"""obj1.speak()
obj2.speak()
obj3.speak()"""

# 封装一个接口，统一的进行调用，后期增加类，不需要增加维护成本
def obj_speak(obj):
    obj.speak()
obj_speak(obj1)
obj_speak(obj2)
class WCS(Animal):
    def speak(self):
        print("哈哈哈")
obj4 = WCS()
obj_speak(obj4)


# python中一切皆对象，数据类型本身就是对象，本身就支持多态性
"""print(len([1,2,3,4]))
print(len("1234"))
print(len((1,2,3)))
print(len({1, 2, 3}))"""

